

{% extends 'base.html' %}

{% block  css-page %}

    <link href="/static/datatable/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css" rel="stylesheet">

    <!-- DataTables Responsive CSS -->
    <link href="/static/datatable/datatables-responsive/css/dataTables.responsive.css" rel="stylesheet">

{% endblock %}



{% block page-content %}
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">服务器添加</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                

                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            服务器信息添加
                        </div>
                        <div  class="panel-body">

                            <!-- Nav tabs -->
                            <ul class="nav nav-tabs">
                                <li class="active"><a data-toggle="tab" href="#oneserver" aria-expanded="true">单台添加</a>
                                </li>
                                <li class=""><a data-toggle="tab" href="#servers" aria-expanded="false">批量添加</a>
                                </li>
                               
                            </ul>

                            <!-- Tab panes -->
                            <div class="tab-content">
                                <div id="oneserver" class="tab-pane fade active in">
                                </br>
                                    <form class="form-horizontal nice-validator n-yellow" method="post"  >

                                        <div class="panel-body">
                                            <div class="col-lg-5">
                                                <div class="panel panel-info">
                                                    <div class="panel-heading">
                                                        基本信息
                                                    </div>
                                                 <div class="ibox-content" style="display: block;">
                                                     <div>
                                                            <br>
                                                                <div class="form-group"><label class="col-sm-3 control-label"> 类型<span class="red-fonts"></span></label>
                                                                    <div class="col-sm-8"><input type="text" class="form-control" name="type" id="type"  required="true" ></div>
                                                                </div>

                                                                <div class="form-group"><label class="col-sm-3 control-label"> CPU<span class="red-fonts"></span></label>
                                                                    <div class="col-sm-8"><input type="text" class="form-control" name="cpu" placeholder="Inter I5-4590"  id="cpu"  required="true" ></div>
                                                                </div>

                                                                <div class="form-group"><label class="col-sm-3 control-label"> 主板<span class="red-fonts"></span></label>
                                                                    <div class="col-sm-8"><input type="text" class="form-control" placeholder="华硕B150-A" name="motherboard"  id="motherboard" required="true"></div>
                                                                </div>

                                                               <div class="form-group"><label class="col-sm-3 control-label"> 内存<span class="red-fonts"></span> </label>
                                                                    <div class="col-sm-8"><input type="text" class="form-control"  name="memory" required="true"></div>
                                                                </div>

                                                                <div class="form-group"><label class="col-sm-3 control-label"> 显卡<span class="red-fonts"></span> </label>
                                                                    <div class="col-sm-8"><input type="text" class="form-control" name="graphics" ></div>
                                                                </div>

                                                                <div class="form-group"><label class="col-sm-3 control-label"> 硬盘<span class="red-fonts"></span> </label>
                                                                    <div class="col-sm-8"><input type="text" class="form-control" name="hard_disk1"  ></div>
                                                                </div>

                                                                <div class="hr-line-dashed"></div>
                                                                <div class="form-group"><label class="col-sm-3 control-label"> 键鼠<span class="red-fonts"></span> </label>
                                                                    <div class="col-sm-8"><input type="text" class="form-control" name="keyboard"  ></div>
                                                                </div>

                                                                <div class="hr-line-dashed"></div>
                                                                <div class="form-group"><label class="col-sm-3 control-label"> 机箱<span class="red-fonts"></span> </label>
                                                                    <div class="col-sm-8"><input type="text" class="form-control" name="chassis"  ></div>
                                                                </div>

                                                                <div class="hr-line-dashed"></div>
                                                                <div class="form-group"><label class="col-sm-3 control-label"> 电源<span class="red-fonts"></span> </label>
                                                                    <div class="col-sm-8"><input type="text" class="form-control" name="power_Supply"  ></div>
                                                                </div>

                                                                <div class="hr-line-dashed"></div>
                                                                <div class="form-group"><label class="col-sm-3 control-label"> 显示器<span class="red-fonts"></span> </label>
                                                                    <div class="col-sm-8"><input type="text" class="form-control" name="monitor"  ></div>
                                                                </div>

                                                              </div>
                                                         </div>
                                                                                            
                                                     </div>
                                                 </div>

                                       <div class="col-lg-7">
                                                                                   
                                            <div class="panel panel-info">
                                                       <div class="panel-heading">
                                                                  基它信息
                                                        </div>
                                            <div class="ibox-content" style="display: block;">


                                            <div>
                                                <br>
                                                    <div class="hr-line-dashed"></div>
                                                                <div class="form-group">
                                                                    <label class="col-sm-2 control-label" >部门 <span class="red-fonts"></span> </label>
                                                                    <div class="col-sm-8">
                                                                        <select class="form-control m-b" name="dept"  >
                                                                            {% for d in Deptdata%}
                                                                                <option value="{{d.id}}"> {{d.name}}</option>
                                                                            {% endfor %}
                                                                        </select>
                                                                    </div>
                                                                </div>

                                                    <div class="hr-line-dashed"></div>
                                                    <div class="form-group"><label class="col-sm-2 control-label"> 使用者<span class="red-fonts">*</span></label>
                                                        <div class="col-sm-8"><input type="text" class="form-control" name="who_uses"  ></div>
                                                    </div>

                                                    <div class="hr-line-dashed"></div>
                                                    <div class="form-group"><label class="col-sm-2 control-label"> 采购价<span class="red-fonts"></span> </label>
                                                        <div class="col-sm-8"><input type="text" class="form-control" name="price"  ></div>
                                                    </div>

                                                    <div class="hr-line-dashed"></div>
                                                     <div class="form-group">
                                                        <label class="col-sm-2 control-label" for="l_applist">供应商<span class="red-fonts"></span> </label>
                                                        <div class="col-sm-6">
                                                            <select class="form-control m-b" name="supplier" >
                                                                {%for i in Supplier%}
                                                                    <option value="{{i.id}}">{{i.supplier_name}}</option>
                                                                {%endfor%}
                                                            </select>
                                                        </div>
                                                    </div>

                                                    <div class="hr-line-dashed"></div>
                                                    <div class="form-group"><label class="col-sm-2 control-label"> 购买时间<span class="red-fonts"></span> </label>
                                                        <div class="col-sm-8"><input type="text" class="form-control" name="datetime"  ></div>
                                                    </div>


                                                <div class="hr-line-dashed"></div>
                                                    <div class="form-group"><label class="col-sm-2 control-label"> 备注<span class="red-fonts"></span> </label>
                                                        <div class="col-sm-8"><textarea rows="3" class="form-control" name="description"></textarea></div>
                                                    </div>

                                            </div>
                                        </div>
                                              
                                
                                        </div>
                                        </div>

                                             {% csrf_token %}

                                                     <div class="form-group">
                                                         <div class="col-sm-4 col-sm-offset-5">
                                                          <button type="reset" class="btn btn-white"> 重置 </button>
                                                          <button type="button" class="btn btn-primary" id="serveradd"> 提交 </button>
                                                         </div>
                                                    </div>
                                            </div>
                                    </form>
                                </div>





                                <div id="servers" class="tab-pane fade">
                                <div class="panel-body" >

                                <br>
                                <p>请严格按照文本框内主机信息格式填写, 多台主机回车换行, 具体格式如下: </p>
                                <p class="text-info">主机名|外网IP|内网IP|虚拟IP|业务|部门|CPU|CPU频率|内存|硬盘|类型|系统|IDC|密码|备注 </p>
                                    <form class="form-horizontal" method="post" action="/server/alladd/">
                                        <div><textarea style="width:700px;height:500px" class="form-control" placeholder="serverv2|192.168.2.3|10.1.1.1|100.222.223.2|数据库服务|运维部|4|2344.3|8|500|1|1|绵阳机房|23424323|sdsdsd" type="text" name="addallserver" id="addallserver"></textarea></div>
                                    </div>

                                        <div class="hr-line-dashed"></div>
                                        <div class="form-group">

                                            <div class="col-sm-4 col-sm-offset-4">
                                                <button type="reset" class="btn btn-white"> 重置 </button>
                                                <button type="button" class="btn btn-primary" id="serveralladd"> 提交 </button>
                                            </div>
                                        </div>
                                    </form>


                                  </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- /.panel -->

                <div class="modal fade" id="myModal" tabindex="-1" role="dialog"  id="myModal" aria-labelledby="myModalLabel">
              <div class="modal-dialog" role="document">
                <div class="modal-content">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">系统提示</h4>
                  </div>
                  <div class="modal-body">
                         <p id="getdata">ddddddd</p>
                  </div>
                    <div class="modal-footer">

                        <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
                        <a class="btn btn-default" href="/cmdb/list/">确定</a>
                    </div>
                </div>
              </div>
            </div>



                </div>
            </div>
            <!-- /.row -->

             <script>
                       $(function(){
                            $("#serveradd").click(function() {
                                $.post("",
                                         {cpu: $("input[name='cpu']").val(),
                                               type: $("input[name='type']").val(),
                                               motherboard: $("input[name='motherboard']").val(),
                                               memory: $("input[name='memory']").val(),
                                               graphics: $("input[name='graphics']").val(),
                                               dept: $("select[name='dept']").val(),
                                               hard_disk1: $("input[name='hard_disk1']").val(),
                                               keyboard: $("input[name='keyboard']").val(),
                                               chassis: $("input[name='chassis']").val(),
                                               power_Supply: $("input[name='power_Supply']").val(),
                                               monitor: $("input[name='monitor']").val(),
                                               who_uses: $("input[name='who_uses']").val(),
                                               price: $("input[name='price']").val(),
                                               supplier: $("select[name='supplier']").val(),
                                               desc: $("input[name='description']").val(),
                                               datetime: $("input[name='datetime']").val(),
                                               csrfmiddlewaretoken: '{{ csrf_token }}'},
                                         function (data) {
                                            $("#getdata").html(data);
                                            $('#myModal').modal('show');
                                        });
                            });

                        });
                  </script>

   {% endblock %}



